//: A UIKit based Playground for presenting user interface
  
import UIKit
import PlaygroundSupport
import JYViewBuilder

class MyViewController : UIViewController {
    override func loadView() {
        
        self.view = VStack(spacing: 8, distribution: .fillEqually){
            label("hello world!")
            for i in 0...5{ //for循环控件添加
                label("\(i)")
            }
            HStack(distribution: .equalSpacing){
                label("hello")
                label("world!")
            }
            if Bool.random() { //分支添加
                HStack(distribution: .equalSpacing){
                    label("hello true")
                    label("true world!")
                }
            } else {
                HStack(distribution: .fillEqually){
                    label("hello false")
                    label("false world!")
                    label("false")
                }
            }
            if Bool.random() { //option分支
                HStack(distribution: .fillEqually){
                    label("hello option")
                    label("option world!")
                }
            }
        }
    }
    
    private func label(_ text: String) -> UILabel {
        let lb = UILabel()
        lb.text = text
        lb.backgroundColor = .lightGray
        
        return lb
    }
}
// Present the view controller in the Live View window
PlaygroundPage.current.liveView = MyViewController()
